﻿function check0to255(str){
	var temp=""
	for(var i=0;i<str.length;i++)
	     if(str.charCodeAt(i)>0&&str.charCodeAt(i)<255)
	        temp+=str.charAt(i)
	return temp
}


//author: peixere@gmail.com
//(new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2008-07-02 08:09:04.423
Date.prototype.Format = function(fmt)
{ 
	var o = {
		"M+" : this.getMonth()+1,
		"d+" : this.getDate(),
		"h+" : this.getHours(),
		"m+" : this.getMinutes(),
		"s+" : this.getSeconds(),
		"q+" : Math.floor((this.getMonth()+3)/3),
		"S" : this.getMilliseconds()
	};
	if(/(y+)/.test(fmt))
		fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
	for(var k in o)
	if(new RegExp("("+ k +")").test(fmt))
		fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
	return fmt;
}
var ie5 = document.all && document.getElementById;
var ns6 = document.getElementById != 'underfined' && document.all == 'underfined';
function OpenWin(title, url){
	xopen('', url,600,500);
}
function xopen(title, url, width, height){	
	var left = screen.width/2-width+width/2;
	if(left<0)left = 50;
	var top = screen.height/2-height+height/2;
	if(top<0)top = 50;	
//	if (!ie5){
		property = "width="+width+", height="+height+",top="+top+",left="+left+",toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no,modal=yes";
		window.open(url,title,property);
		//window.close();
//	}else{
//		window.showModalDialog(url,title,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;dialogTop="+top+"; dialogLeft="+left+";help=no;status=no;resizable=no;scroll=yes;");	
//	}
}


function check(msg,lengthMsg)
{
  if(document.forms[0].pass.value.length<3||document.forms[0].enterPass.value.length<3){ 
    alert(lengthMsg);
    return false;
  }
  if(document.forms[0].pass.value==document.forms[0].enterPass.value){
   document.forms[0].password.value=document.forms[0].enterPass.value;
    return true;
  }else{
    alert(msg);
    return false;
  }
}

function password(msg)
{
   alert(msg);
  
  function flushOpener(){
	if(opener.document.forms[0]!=undefined){
		opener.document.forms[0].submit();
	}else{
		//alert(opener.location);
		opener.location.reload();
	}
	window.close();
   }
   flushOpener(); 
}

function commonsFlush()
{ 
	if(opener.document.forms[0]!=undefined){
		opener.document.forms[0].submit();
	}else{
		//alert(opener.location);
		opener.location.reload();
	}		
}
function windowClose()
{
   	window.close();
}

function strSubstring(str,start,slength)
{
   var s=str.substring(start,slength);
   return s;
}


function InsertHTML(value)
{
	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance('content') ;

	// Check the active editing mode.
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
	{
		// Insert the desired HTML.
		oEditor.InsertHtml(value) ;
	}
	else
		alert( 'You must be on WYSIWYG mode!' ) ;
}



function Logout(ctx){
	if(confirm('您确认退出系统？')){
		location.href=ctx+'/login.do?method=logout';		
	}
}